package com.aistar.mapper;

import com.aistar.model.entity.Company;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface CompanyMapper {
    //查看全部信息
    @Select("select * from company")
    List<Company> find();

    //根据公司id获取公司信息
    @Select("select * from company where id=#{id}")
    Company findById(Integer id);

    //根据公司id获取部分公司信息
    @Select("select id,name,num,province,city,district,area,logo,introduction from company where id=#{id}")
    Company partCompany(Integer id);

    //根据公司实体修改公司信息
    @Update("update company set name=#{name},num=#{num},province=#{province},city=#{city},district=#{district},area=#{area},logo=#{logo},introduction=#{introduction},business_name=#{businessName},established_time=#{establishedTime},financing=#{financing},industry_type=#{industryType},representative=#{representative},registered_amount=#{registeredAmount},license=#{license} where id=#{id}")
    int updateById(Company company);

    //根据公司名称获得信息
//    @Select("select * from company where name like concat('%',#{name},'%')")
    List<Company> findByName(@Param("name") String name, @Param("financing") String financing, @Param("num") String num,@Param("province")String province,@Param("city")String city,@Param("district")String district);

    //根据城市查找公司id
//    @Select("select id from company where city=#{city}")
    List<Integer> findByCity(@Param("province")String province,@Param("city") String city,@Param("district")String district);
}
